package com.oscarmovie.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.oscarmovie.Constants;
import com.oscarmovie.model.Calendar;
import com.oscarmovie.service.CalendarService;

public class CalendarAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	private CalendarService calendarService;
	
	private Calendar calendar;
	private List<Calendar> calendars;

	public String add() throws Exception {
		setCalendar(null);
		return Constants.ADD;
	}
	public String edit() throws Exception {
		loadAll();
		load();
		return Constants.EDIT;
	}

	public String save() throws Exception {
		calendarService.save(calendar);
		return edit();
	}

	public String load() throws Exception {
		this.calendar = calendarService.load(calendar.getId());
		return SUCCESS;
	}

	public String loadAll() throws Exception {
		this.calendars = calendarService.loadAll();
		return SUCCESS;
	}


	public List<Calendar> getCalendars() {
		return calendars;
	}

	

	public void setCalendarService(CalendarService calendarService) {
		this.calendarService = calendarService;
	}

	public void setCalendar(Calendar calendar) {
		this.calendar = calendar;
	}

	public Calendar getCalendar() {
		return calendar;
	}


}
